//
//  BaseWKWebViewController.m
//  KEREN
//
//  Created by MW on 2023/4/25.
//

#import "BaseWKWebViewController.h"
#import <WebKit/WebKit.h>



@interface BaseWKWebViewController ()<WKNavigationDelegate,WKUIDelegate>

@property (nonatomic, strong)WKWebView *webView;
@property (nonatomic, strong)WKWebViewConfiguration *webConfig;

//@property (nonatomic ,strong) 
 
@end

@implementation BaseWKWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (WKWebView *)webView{
    if (!_webView) {
        _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, DEVICE_HEIGHT) configuration:self.webConfig];
        _webView.UIDelegate = self;
        if (@available(iOS 11.0, *)) {
           [[WKWebsiteDataStore defaultDataStore] httpCookieStore];
        }
        _webView.allowsBackForwardNavigationGestures = YES;
    }
    return _webView;
}
- (WKWebViewConfiguration *)webConfig{
    if(!_webConfig){
        _webConfig = [[WKWebViewConfiguration alloc] init];
        WKPreferences *preference = [[WKPreferences alloc]init];
        preference.minimumFontSize = 0;
        preference.javaScriptEnabled = YES;
        preference.javaScriptCanOpenWindowsAutomatically = YES;
        _webConfig.preferences = preference;
        _webConfig.allowsInlineMediaPlayback = YES;
  
        _webConfig.processPool = [[WKProcessPool alloc]init];
    }
    return _webConfig;
}

@end
